//发送ajax请求
// 封装功能函数
// http://43.142.171.249
// http://127.0.0.1:3300

const cookies = wx.getStorageSync('cookie')
export default (url, data = {},method = 'POST', cookie) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url:'http://43.142.171.249'+ url,
      header:{'cookie':cookie || cookies},
      data,
      timeout:100000,
      method,
      success: (res) => {
        // console.log('请求成功', res);
        resolve(res.data)
      },
      fail: (err) => {
        // console.log('请求失败', err);
        reject(err)
      }
    })
  })
}